package com.learn.common;


import lombok.Data;

@Data
public class Response<T> {
    private T data;
    private String message;
    private String status;


    public static <T> Response<T> of(T data) {
        Response<T> response = new Response<>();
        response.status = "OK";
        response.message = null;
        response.data = data;
        return response;
    }

    public static <T> Response<T> success(T object) {
        Response<T> r = new Response<>();
        r.status = "OK";
        r.message = null;
        r.data = object;
        return r;
    }


    public static <T> Response<T> error(String message) {
        Response r = new Response();
        r.status = "ERROR";
        r.message = message;
        r.data = null;
        return r;
    }
}
